import { _decorator, Vec3 , Node} from 'cc';
import { SkillManager } from './SkillManager';
import { EBuff, EGroup, EntityType, ESkill } from '../Config/Enum';
import ObjectPoolManager from '../Core/ObjectPoolManager';
import { Collider2D } from 'cc';
import { PlayerManager } from '../PlayerManager';
import { buffConfig, SkillConfig } from '../Config/SkillConfig';
import { EnemyManager } from '../EnemyManager';

const { ccclass } = _decorator;
// 陷阱的爆炸
// 符文1 - 七绝杀阵 再次重置
// 符文2 - 困兽犹斗 陷阱爆炸范围扩大100%，控制+1秒
// 符文3 - 毒爆送葬 陷阱造成连锁爆炸


@ccclass('TangmenExplosion')
export class TangmenExplosion extends SkillManager {

    runeId
    effectChance
    buffTypeList
    buffDuration
    playSpeed: number;



    

    // 新增标志：是否是主子弹（由玩家直接发射的子弹）
    pm

    init(type: ESkill, pm: PlayerManager) {

        // 重置所有状态
        this.pm = pm;
        //this.reset();
        super.initOtherSkill(type, pm);


        // 其他符文效果
        switch (this.runeId) {
            case 1:

                break;
            case 2:
                // 符文2: 陷阱范围扩大50%，控制+1秒
                this.node.setScale(2, 2, 1); //

                break;  
            case 3:


                break;
        }

        console.log("TangmenExplosion init pm", this.pm);


    }

    protected onHitEnemy(self, other: Collider2D): void {
        this.em = other.node.getComponent(EnemyManager);

        this.applyBuffToEnemy(this.em,0.5, EBuff.Poison, 0, 3); // 中毒
        this.applyBuffToEnemy(this.em,0.5, EBuff.Stun, 0, 3); // 晕眩
        this.applyBuffToEnemy(this.em,0.5, EBuff.Vulnerable, 0.4, 3); // 易伤

        switch (this.runeId) {
            case 1:

                break;
            case 2:

                break;
            case 3: // TODO
                this.applyBuffToEnemy(this.em, 0.5,EBuff.Fear, 0, 1); // 恐惧
                break;
            default:
                break;
        }

        super.onHitEnemy(self, other);

    }



// reset() {
//     this._hasSplit = false;
//     this.isMasterBullet = true;
//     this.direction = new Vec3(0, 0, 0);
//     this._contactPosition = new Vec3(0, 0, 0);
// }





}